<?
$g4_path = "../.."; // common.php 의 상대 경로
include_once("$g4_path/common.php");
if($shotbirdie_tkey){
 $ti_de = urldecode($shotbirdie_tkey);
 $g4[title] = "오마이토렌트 검색 : $ti_de";
}else{
 $g4[title] = "오마이토렌트 검색";
}
@include_once("$g4[path]/head.php");
?>
<script language="Javascript" type="text/Javascript">
<!--
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
//-->
</script>
<style>

.jyGuideBox {margin-top:30px; padding:20px; background:#f2f2f2;}
.jyGuideBox .txt_title {padding-left:20px; height:17px; line-height:19px; font-weight:bold; color:#333; background:url('./img/ico_sprites_bule.gif') no-repeat 2px 2px;}
.jyGuideBox ul {padding-top:8px;}
.jyGuideBox li {padding-left:20px; height:18px; line-height:20px; font-size:11px; color:#999; list-style:none; background:url('./img/ico_sprites_bule.gif') no-repeat 10px -30px;}
</style>
<!--상단검색-->
<table width="730"  border="0" align="center" cellpadding="0" cellspacing="0">
                              <tr>
                                <td width="29"><img src="img/search_left.gif" width="29" height="79"></td>
                                <td valign="top" background="img/search_bodybg.gif"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td height="40"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                          <tr>
                                            <td width="3" height="6"></td>
                                            <td height="6"></td>
                                          </tr>
                                          <tr>
                                            <td>&nbsp;</td>
                                            <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                  <td width="150" class="search_txt">오마이토렌트 검색</td>

                                                  
                                                   
                                                </div></td>
                                                </tr>
                                            </table></td>
                                          </tr>
                                      </table></td>
                                    </tr>
                                    <tr>
                                      <td height="39"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <form type="get" action="<?=$PHP_SELF_SELF?>">
                                            <tr>
                                              <td><input name=shotbirdie_tkey maxlength=30 itemname="토렌트 검색어" required value='<?=$shotbirdie_tkey?>' style="width:620; height:22px;"></td>
                                              <td width="60"><div align="right">
                                                  <input name="image" type=image src="img/search_bt.gif" align=absmiddle  width="49" height="21" border=0>
                                              </div></td>
                                            </tr>
                                        </form>
                                      </table></td>
                                    </tr>
                                </table></td>
                                <td width="20"><img src="img/search_right.gif" width="20" height="79"></td>
                              </tr>
</table>
<!--상단검색-->
<center>마그넷 주소를 이용하여 다운로드 하세요</center>
<?
if($shotbirdie_tkey == ''){ }else{
require 'lib/Snoopy.class.php'; 
ini_set("allow_url_fopen","1"); 
switch($sort_code){
 case 'a': //최근
  $sort = "a/d/";
  $scolor01 = "style='color: #990000;'";
  break;
 case 'c': //인기
  $sort = "c/d/";
  $scolor02 = "style='color: #990000;'";
  break;
 case 's': //시더
  $sort = "s/d/";
  $scolor03 = "style='color: #990000;'";
  break;
 case 'n': //이름
  $sort = "n/d/";
  $scolor04 = "style='color: #990000;'";
  break;
 case 'z': //크기
  $sort = "z/d/";
  $scolor05 = "style='color: #990000;'";
  break;
 default: //인기
  $sort = "c/d/";
  $scolor02 = "style='color: #990000;'";
  $tpage = 1;
  break;
}
switch($tpage){
 case '1': 
  $tcolor01 = "style='color: #990000; font-weight:bold;'";
  break;
 case '2': 
  $tcolor02 = "style='color: #990000; font-weight:bold;'";
  break;
 case '3': 
  $tcolor03 = "style='color: #990000; font-weight:bold;'";
  break;
 default: 
  $tcolor02 = "style='color: #990000; font-weight:bold;'";
  break;
}
$url = "http://bitsnoop.com/search/all/".$shotbirdie_tkey."/".$sort.$tpage."/?fmt=rss";
  $snoopy = new Snoopy; 
  $snoopy->fetch($url); 
  $xml = @simplexml_load_string($snoopy->results); 
  $listct = '30'; //첫 파싱후 2번째부터는 수량조절용으로 사용(최적화를 위해)
  //$listct = count($xml->item);
 
//테이블상단
echo "
<br><br>
<table width='740' height='30' border='0' align='center' cellpadding='0' cellspacing='0'>
  <tr>
    <td>
<table width='100%'  border='0' cellspacing='5' cellpadding='0'>
  <tr>
   
    <td width='50%' align='right'>
<!--순서-->
<a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=a&tpage=$tpage'><span $scolor01>최신순</span></a> | 
<a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=c&tpage=$tpage'><span $scolor02>인기순</span></a> | 
<a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=s&tpage=$tpage'><span $scolor03>시드순</span></a> | 
<a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=n&tpage=$tpage'><span $scolor04>이름순</span></a> | 
<a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=z&tpage=$tpage'><span $scolor05>크기순</span></a> 
 </td>
  </tr>
</table>
 </td>
  </tr>
</table>
<table width='730' border='0' align='center' cellpadding='0' cellspacing='0'>
  <tr>
    <td><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
      <tr>
        <td height='1' bgcolor='BFBFBF'></td>
      </tr>
      <tr>
        <td height='32' bgcolor='FAFAFA'><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
          <tr>
            <td width='38' align='center'>번호</td>
            <td width='500' align='center'>제목</td>
            <td width='66' align='center'>크기</td>
            <td width='38' align='center'>시드</td>
            <td width='44' align='center'>마그넷</td>
            <td width='44' align='center'>토렌트</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height='1' bgcolor='EDEDED'></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
";
  for($i=0; $i<$listct; $i++){
    $wr_subject[$i] = $xml->channel->item[$i]->title;
    $category[$i] = $xml->channel->item[$i]->category;
    $link[$i] = $xml->channel->item[$i]->link;
    $pubDate[$i] = $xml->channel->item[$i]->pubDate;
    $numSeeders[$i] = $xml->channel->item[$i]->numSeeders;
    $numLeechers[$i] = $xml->channel->item[$i]->numLeechers;
    $numFiles[$i] = $xml->channel->item[$i]->numFiles;
    $numComments[$i] = $xml->channel->item[$i]->numComments;
    $size[$i] = $xml->channel->item[$i]->size;
    $fileName[$i] = $xml->channel->item[$i]->torrent->fileName;
    $url_join[$i] = 'http://torrage.com/torrent/'.$fileName[$i];
    $contentLength[$i] = $xml->channel->item[$i]->torrent->contentLength;
    $infoHash[$i] = $xml->channel->item[$i]->torrent->infoHash;
    $magnetURI[$i] = $xml->channel->item[$i]->torrent->magnetURI;
    $wr_content[$i] = $xml->channel->item[$i]->description;
    //echo "$wr_subject / $fileName / $url_join<br>";
    //순번
    $num = $i+1;
    //파일용량
    $size[$i] = round(($size[$i] / 1024)/1024);
    

    //회원가입에 따른차등
    if(!$member['mb_id']){ 
     //안내메세지
     
     $tmsg = "오른쪽 배너 광고 클릭은 토렌토검색 서버운영에 도움이됩니다. ^^";
     $timeinfo = getdate(time());
     if(($timeinfo[hours] >= '00' and $timeinfo[hours] < '11') or ($timeinfo[hours] >= '11' and $timeinfo[hours] < '16') or ($timeinfo[hours] >= '16' and $timeinfo[hours] < '24')){
      $magnetURI_m[$i] = "<a href='$magnetURI[$i]' target='_blank'  onClick=\"MM_popupMsg('$tmsg')\"><img src='img/torrent_img01.GIF' border='0'></a>";
      $url_join_m[$i] = "<a href='$url_join[$i]' target='_blank'  onClick=\"MM_popupMsg('$tmsg')\"><img src='img/torrent_img02.GIF' border='0'></a>";
     }else{
      $magnetURI_m[$i] = "<a href='http://www.ohmytorrent.com' target='_blank'  onClick=\"MM_popupMsg('$tmsg-가입 후 로그인 하세요')\"><img src='img/torrent_img01.GIF' border='0'></a>";
      $url_join_m[$i] = "<a href='http://www.ohmytorrent.com' target='_blank'  onClick=\"MM_popupMsg('$tmsg-가입 후 로그인 하세요')\"><img src='img/torrent_img02.GIF' border='0'></a>";
     }
    }else{ //로그인시
     $magnetURI_m[$i] = "<a href='$magnetURI[$i]'><img src='img/torrent_img01.GIF' border='0'></a>";
     $url_join_m[$i] = "<a href='$url_join[$i]'><img src='img/torrent_img02.GIF' border='0'></a>";
    }

   //중복내용
    echo "
     <table width='100%'  border='0' cellspacing='0' cellpadding='0'>
        <tr>
       <td><table width='100%' height='33'  border='0' cellpadding='0' cellspacing='0'>
         <tr>
        <td width='38' align='center'>$num</td>
        <td width='500'>$wr_subject[$i]</td>
        <td width='66' align='center'>$size[$i]MB</td>
        <td width='38' align='center'>$numSeeders[$i]</td>
        <td width='44' align='center'>$magnetURI_m[$i]</td>
        <td width='44' align='center'>$url_join_m[$i]</td>
         </tr>
       </table></td>
        </tr>
        <tr>
       <td height='1' bgcolor='EDEDED'></td>
        </tr>
      </table>
     ";
    //echo "$num - <a href='$url_join[$i]' target='_blank'>$wr_subject[$i]</a><br>";
  }//end for($i)
//테이블하단
echo "
 </td>
  </tr>
  <tr>
 <td align='center'>
<!--페이지-->
   <a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=$sort_code&tpage=1'><span $tcolor01>1</span></a> |
   <a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=$sort_code&tpage=2'><span $tcolor02>2</span></a> | 
   <a href='$PHP_SELF_SELF?shotbirdie_tkey=$shotbirdie_tkey&sort_code=$sort_code&tpage=3'><span $tcolor03>3</span></a>
  </td>
  </tr>
</table>
";
} //end if(shotbirdie_tkey)
?>

<?
//유가정보

?>
<?
@include_once("$g4[path]/tail.php");
?>